<script src="../scripts/jquery-1.5.1.js"></script>
<script>
          
         $(document).ready(function(){
                          $("#book_food tbody a").click(function (){
                  $.get($(this).attr('href'),function (data){
                      $("#foods").html(data);
                    
                     
                  })
                  return false;
              }); 
         });
</script>

<?php
    session_start();
    require_once '../lib/Modelsphp.php';
        $k=new Modelsphp();     
        
        
   
   if(isset($_GET['xoa']) &&isset($_GET['masp'])) 
   {
       $id=$_GET['masp'];
       if(isset($_SESSION['cart'][$id]))
                unset($_SESSION['cart'][$id]);
   }
//        unset($_SESSION['cart']);
   if(isset($_GET['ac']) &&isset($_GET['masp']))
     
   {
        $id=$_GET['masp'];
      
        $_SESSION['cart'][$id]=0;
        
   }
   
   
 if(isset($_SESSION['cart'])) 
   {
     if(count($_SESSION['cart'])>0)
   {
    foreach($_SESSION['cart'] as $key=>$value)
    {
        $ch=$key.'</br>';
        $item[]=$key;
    }
//    echo $ch;
//    
//    
//    if(array_count_values($_SESSION['cart'])==1) $str=$item[0];
//else {
//        $item[]=1;
//        $item[]=2;
    
  $str=implode(',',$item);
//}
//     echo $str;
        $db=$k->getCart($str);
        $i=0;
?>

<style>
   
     a
    {
        text-decoration: none;
    }
    #book_food
    {
        
        border-collapse: collapse;
        /*border: 1px #003cb3 solid;*/
         color: #0092ef;
         margin: 0 auto;
    }
     #book_food thead td
     {
         font-weight: bold;
     }
    #book_food td, tr 
    {
        border-bottom: 1px #003cb3 dotted;
        text-align: center;
       
    }
    #menu_bg
    {
        min-height: 300px;
       /*background: no-repeat scroll 0 -16px rgba(0, 0, 0, 0);*/
       background-image:url("../Images/cooker.png") ;
       background-repeat: no-repeat;
       background-size: 250px;
       background-position: 0 16px;
    }
    .but_cont
    {
         background-color: #7fbf4d;
    border: 2px solid #63a62f;
    border-radius: 8px;
    box-shadow: 0 2px 3px #666666;
    color: #ffffff;
    font-family: "Lucida Grande","Lucida Sans Unicode","Lucida Sans",Geneva,Verdana,sans-serif;
    font-size: 13px;
    font-style: normal;
    font-variant: normal;
    font-weight: normal;
    line-height: 1;
    margin-top: 10px;
    margin-left: 10px;
    padding: 6px 8px;
    text-align: center;
    text-shadow: 0 -1px 0 #4c9021;
    width: 70px;
    }
    #book_food tbody tr td img 
    {
        width: 20px;
        height: 20px;
    }
    fieldset
    {
       /*background-color: #7fbf4d;*/
    border: 2px solid #63a62f;
    border-radius: 8px;
    box-shadow: 0 2px 3px #666666;
    /*color: #ffffff;*/
    font-family: "Lucida Grande","Lucida Sans Unicode","Lucida Sans",Geneva,Verdana,sans-serif;
/*    font-size: 13px;
    font-style: normal;
    font-variant: normal;
    font-weight: normal;
    line-height: 1;
*/    margin: 6px 8px;/*
    text-align: center;*/
    text-shadow: 0 -1px 0 #4c9021;
    /*width: auto;*/
    }
    fieldset legend
    {
        color:#4c9021; 
    }
</style>
                <form action="" method="" >
                        <fieldset >
                            <div id="menu_bg">
                            <legend>Các Món đã Đặt</legend>
                            <table id="book_food">
                                <thead>
<!--                                    <tr>
                                        <td>Số TT</td>
                                        <td>Tên Món</td>
                                        <td>Xóa</td>
                                    </tr>-->
                                    
                                </thead>
                                <tbody>
                                    <?php
                                    while ($row = mysqli_fetch_array($db)) {
                                        $i++;
                                   
                                    ?>
                                    <tr>
                                        <td><?php echo $i.'.';?></td>
                                        <td><?php echo $row['title'];?></td>
                                        <td><a href="<?php echo $_SERVER['PHP_SELF'].'?xoa=xoa&masp='.$row['id']; ?> " style="margin-left: 10px;"><img src="../Images/del.ico"/ ></a></td>
                                    </tr>
                                    <?php
                                    
                                    }
                                    ?>
                                </tbody>
                                
                            </table>
                            
                            </div>
                            <a href="../book/contact.php"> <input type="button" value="Liên hệ" class="but_cont"></a>
                        </fieldset>
                </form>
               <?php 
   
   }
   }
   ?>